package com.example.beryl.http;
import com.example.beryl.Util.Android_log;
import com.example.beryl.entity.Action;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 裁切开工网络方法
 */
public class Net_cuttingStart {
    private ArrayList<String> arrayList = new ArrayList<String>();
    private ArrayList<String> brrayList = new ArrayList<String>();
    private ArrayList<String> crrayList = new ArrayList<String>();
    private Net_method soap2 = new Net_method();

    //private static String URL ="CuttingStart.asmx";//服务器地址
    private static String URL ="CuttingStart.asmx";//调试地址

    public List<String> CS_CommonMethod(String what, String para)
    {

        List<String> list = new ArrayList<>();
        try
        {
            switch (what)
            {
                case Action.action.GetBarcode:
                list =  getBarCode(para);
                break;
                case Action.action.GetKn:
                    list = getKn(para);
                    break;
                case Action.action.CS_Summit:
                    list = Summit(para);
            }

        }catch (Exception e)
        {

        }
        return list;
    }

    //裁切开工记录查询方法
    public List<String> getBarCode(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("barcode");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("selectBarCode", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    //查询刀具组信息
    public List<String> getKn(String para)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(para);
        try
        {
            crrayList = soap2.SummitData("selectgetKn", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    //裁切开工记录提交
    public List<String> Summit(String data)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        arrayList.add("summit");
        brrayList.add(data);
        try
        {
            crrayList = soap2.SummitData("Summit", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }
}
